package cn.kzgg.ymcc.schedule;

import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import java.util.Date;

@Configuration
@EnableScheduling//定时任务
@EnableAsync//多线程模式
public class TimeSchedule {

    @Async
    @Scheduled(cron = "1/3 * * * * ?")
    public void test(){
        Date now = new Date(System.currentTimeMillis());
        String name = Thread.currentThread().getName();
        System.out.println(now+"执行定时器"+name);

    }
}
